<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{$school['title']}</title>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width initial-scale=1.0 maximum-scale=1.0 user-scalable=yes" />
<link type="text/css" rel="stylesheet" href="{OSSURL}public/mobile/css/bindingFormFor.css" />
<link type="text/css" rel="stylesheet" href="{OSSURL}public/mobile/css/greenStyle.css?v=4.60120" />
<script type="text/javascript" src="{MODULE_URL}public/mobile/js/jquery-1.11.3.min.js?v=4.6"></script>
<script src="{MODULE_URL}public/mobile/js/jquery.js"></script>
<script src="{OSSURL}public/mobile/js/PromptBoxUtil.js"></script>
<style>

#birthday{
border-bottom:1px solid #c6c6c6;position:relative;display:block;height:30px;line-height:30px;opacity:1;
}
#selMonth{
margin-left:-40px;
position:relative;
z-index:10;
opacity:0;
}

</style>
</head>
	<body>
		<div class="all">
			<div class="header mainColor">
				<div class="l">
					<a class="backOff" style="background:url({OSSURL}public/mobile/img/ic_arrow_left_48px_white.svg) no-repeat;background-size: 55% 55%;background-position: 50%;" href="javascript:history.go(-1);"></a>
				</div>
				<div class="m">
					<span>报名申请</span>
				</div>
				<div class="r">
					<a style="font-size:16px;font-weight:bold;position:absolute;color:#f3f3f3;text-align:left;" href="{php echo $this->createMobileUrl('signuplist',array('schoolid'=>$schoolid), true)}">
						记录
					</a>
				</div>			
			</div>
			<div class="_header"></div>
			<div class="bangdingForm">
				{if $school['is_sign'] == 1}
				<div class="bangdingBox">
<!-- 					<div class="headerBox">
						<div class="centerHeader">
							<img id="wxiconpath" onclick="wximgchoos" alt="" src="{php echo tomedia($_W['fans']['tag']['avatar']);}" />
						</div>
					</div> -->
					<div id="parentBox" class="changeBox activeBox">
						<ul>
							<li>
								<span class="l">学生姓名：</span>
								<span class="r">
									<input id="s_name" type="text" value="" />
								</span>
							</li>							
							<li>
								<span class="l">手机号码：</span>
								<span class="r">
									<input id="mobile" type="tel" maxlength="11" value="" />
								</span>
							</li>
							<li>
								<span class="l">性&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;别：</span>
								<span class="r">
									<label>请选择</label>
									<select id="sex">
										<option value="">请选择</option>
										<option value="1">男</option>
										<option value="2">女</option>
									</select>
									<i></i>
								</span>
							</li>

							<li>
								<span class="l">年&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;级：</span>
								<span class="r">
									<label>请选择</label>
										<select id="njid">
											<option value="">请选择</option>
										{loop $njlist $row}
											<option value="{$row['sid']}">{$row['sname']}</option>
										{/loop}	
										<input type="hidden" name='njidids[]' id='njidid' value='' >
										</select>
									<i></i>
								</span>
							</li>

							{if $signset['is_bj'] == 1}							
							<li>
								<span class="l">班&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;级：</span>
								<span class="r">
									<label>请选择</label>
									<div id="bjid">
										
									</div>
									
									<i></i>
								</span>
							</li>
							{/if}
							{if $signset['is_idcard'] == 1}							
							<li>
								<span class="l">身份证号：</span>
								<span class="r">
									<input id="idcard" type="tel" maxlength="18" value="" />
								</span>
								<br>
								<span class="remind">
									<label>请用 * 代替身份证中的X</label>
								</span>
							</li>
							{/if}							
							{if $signset['is_bir'] == 1}
							<li>
								<span class="l">生&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;日：</span>
								<span class="r">
									<input id="birthday" type="date" />
								</span>
							</li>
							{/if}	
							<li class="no_padding">
								<span class="l"></span>
								<span class="remind">
									<i><img alt="" src="{OSSURL}public/mobile/img/ico_attention.png" /></i>
									<label>报名时输入的手机号码是您绑定学生的重要依据</label>
								</span>
							</li>
							{if $signset['is_bd'] == 1}
							<li>
								<span class="l">选择关系：</span>
								<span class="r">
									<label>请选择</label>
										<select id="subjectId">
											<option value="">请选择</option>
											<option value="2">母亲</option>
											<option value="3">父亲</option>
											<option value="4">本人</option>											
										</select>
									<i></i>
								</span>
							</li>							
							{/if}
						</ul>
						<div class="submitBtn mainColor" onclick="Tijiao();">提交</div>
					</div>
				</div>
				{else}
				<div class="bangdingBox">
					<div id="parentBox" class="changeBox activeBox">
						<ul>
							<li class="no_padding">
								<span class="remind">
									<i><img alt="" src="{OSSURL}public/mobile/img/ico_attention.png" /></i>
									<label>抱歉！本校关闭了微信端报名系统！</label>
								</span>
							</li>
						</ul>
					</div>
				</div>
				{/if}
			</div>
		</div>
	</body>	
<script type="text/javascript">
var PB = new PromptBox();
var campus = $("#campus").val();
var subjectId = $('#subjectId').val();
$(document).ready(function() {
	$("#njid").change(function() {
		var type = 2;
		var gradeId = $("#njid option:selected").attr('value');
		changeNj();
		changeGrade(gradeId,type, function() {
		});	
		
	});
	$("#bjid").change(function() {
		changeBj();
	});
	$("#sex").change(function() {
		changeSex();
	});
	$("#subjectId").change(function() {
		changeGx();
	});	
});
function changeNj(){
	$("#njid").parent().find("label").html($("#njid").find("option:selected").text());
}
function changeBj(){
	$("#bjid").parent().find("label").html($("#bjid").find("option:selected").text());
}
function changeSex(){
	$("#sex").parent().find("label").html($("#sex").find("option:selected").text());
}
function changeGx(){
	$("#subjectId").parent().find("label").html($("#subjectId").find("option:selected").text());
}
function changeGrade(gradeId, type, __result) {
	
	//$('#njidid').val(gradeId);
	
	var schoolid = "{$schoolid}";
	var classlevel = [];
	//获取班次
	$.post("{php echo $this->createMobileUrl('indexajax',array('op'=>'getbjlist'))}", {'gradeId': gradeId, 'schoolid': schoolid}, function(data) {
	
		data = JSON.parse(data);
		classlevel = data.bjlist;
		
		var html = '';
		html += '<select id="bj_id"><option value="">请选择班级</option>';
		if (classlevel != '') {
			for (var i in classlevel) {
				html += '<option value="' + classlevel[i].sid + '">' + classlevel[i].sname + '</option>';
			}
		}
		
		$('#bjid').html(html);
	});

}


function Tijiao(){
	var activeBoxID = $(".bangdingBox").find(".activeBox").attr("id");
	var isidcard = "{$signset['is_idcard']}";
	var isbj = "{$signset['is_bj']}";
	var isbir = "{$signset['is_bir']}";
	var isbd = "{$signset['is_bd']}";
	var s_name = $("#s_name").val();
	if(activeBoxID == "parentBox"){
		if($("#sex").val() == null || $("#sex").val() == ""){
			PB.prompt("请选择性别！");
			return;
		}	
		if($("#s_name").val() == null || $("#s_name").val() == ""){
			PB.prompt("学生姓名不能为空！");
			return;
		}


		function ischinese(s){
			var ret=true;
			for(var i=0;i<s.length;i++)           //遍历每一个文本字符
				ret=ret && (s.charCodeAt(i)>=10000);//判断文本字符的unicode值
			return ret;
		} 

		var val= ischinese(s_name);               //判断是否包含中文
		if(!val){
			PB.prompt("学生姓名不能包含英文或符号");
			return;
		}
            		
		if($("#mobile").val() == null || $("#mobile").val() == ""){
			PB.prompt("手机号码不能为空！");
			return;
		}
		if(!$("#mobile").val().match(/^(0|86|17951)?(13[0-9]|15[012356789]|17[0-9]|18[0-9]|14[57])[0-9]{8}$/)){
			PB.prompt("手机格式不正确！");
			return;
		}	
		if(isbir == 1){	
			if($("#birthday").val() == null || $("#birthday").val() == ""){
				PB.prompt("请输入出身日期");
				return;
			}
		}
		if(isidcard == 1){	
			if($("#idcard").val() == null || $("#idcard").val() == ""){
				PB.prompt("请输入身份证号码");
				return;
			}	
		}
		
		if($("#njid").val() == null || $("#njid").val() == ""){
			PB.prompt("请选择年级");
			return;
		}
		
		if(isbj == 1){
			if($("#bj_id").val() == null || $("#bj_id").val() == ""){
				PB.prompt("请选择班级");
				return;
			}
		}
		if(isbd == 1){	
			if($("#subjectId").val() == null || $("#subjectId").val() == ""){
				PB.prompt("请选择与学生关系");
				return;
			}
		}		
	}
	if(confirm("确认提交？")){
		var submitData = {
			openid :"{$openid}",
			schoolid :"{$schoolid}",
			weid :"{$weid}",
			uid :"{$fan['uid']}",
			s_name : $("#s_name").val(),
			sex : $("#sex").val(),
			birthday : $("#birthday").val(),
			njid : $("#njid").val(),
			bjid : $("#bj_id").val(),
			idcard : $("#idcard").val(),
			mobile : $("#mobile").val(),
			pard : $("#subjectId").val(),
		};
	        $.post("{php echo $this->createMobileUrl('indexajax',array('op'=>'signup'))}",submitData,function(data){
            if(data.result){
                PB.prompt(data.msg);
				window.location.href = "{php echo $this->createMobileUrl('signuplist', array('schoolid' => $schoolid), true)}"
            }else{
                PB.prompt(data.msg);
            }
        },'json'); 
    }
}
</script>
</html>